<!DOCTYPE html>
<html data-th-fragment="header"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="UTF-8">
   <!-- <title th:text="${userModel.title}">welcome</title>-->

    <!-- Tether core CSS -->
    <link href="../../css/tether.min.css" th:href="@{/css/tether.min.css}" rel="stylesheet">

    <!-- Bootstrap CSS -->
      <link href="../../css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

    <!-- Font-Awesome CSS -->
    <link href="../../css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet">

    <!-- Custom styles -->
    <link href="../../css/style.css" th:href="@{/css/style.css}" rel="stylesheet">
    <link href="../../css/blog.css" th:href="@{/css/blog.css}" rel="stylesheet">
   <!-- <script src="../../js/bootstrap.min.js" th:src="@{/js/jquery-3.1.1.min.js}"></script>
    <script src="../../js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>-->
</head>
<body>
<nav class="navbar navbar-inverse bg-inverse navbar-toggleable-md">
    <div class="container">
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarsContainer">
            <span class="navbar-toggler-icon"></span>
        </button>
        <a class="navbar-brand" href="/" th:href="@{~/}">Security In Action</a>
        <div  class="collapse navbar-collapse" id="navbarsContainer">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item">
                    <a class="nav-link" href="/users" th:href="@{~/users}">首页</a>
                </li>
            </ul>

            <!--登录判断：如果已登录，显示用户名和退出按钮-->
            <div sec:authorize="isAuthenticated()" class="row">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                      <span class="nav-link" sec:authentication="name"></span>
                    </li>
                </ul>
                <form action="/logout" th:action="@{/logout}" method="post">
                    <input class="btn btn-outline-success" type="submit" value="退出">
                </form>

            </div>
            <!--登录判断：如果未登录，显示登录按钮-->
            <div sec:authorize="isAnonymous()">
                <a href="/login" th:href="@{~/login}" class="btn btn-outline-success my-2 my-sm-0" type="submit">登录</a>
            </div>
        </div>


    </div>
</nav>
</body>
</html>